#ifndef PL_SDL_MIXER_H
#define PL_SDL_MIXER_H

#define PLSDLMIXER_OBJ_ID 141453

#include "../core/AbstractObject.h"
#include "../core/ObjectFactory.h"
#include "../core/SimpleImage.h"
#include "../core/RefTable.h"
#include "SDL_mixer.h"

//OBJTYPE PlSDLMixer
class PlSDLMixer : public AbstractObject
{
public:
	PlSDLMixer();

	// Return the c++ type id
	virtual int getCppTypeId();
	// Returns whether this can be cast to a given type
	virtual bool isType(int id);

	// Return the c++ type as a string 
	virtual std::string getCppTypeName();

	// returns a description of this thing
	virtual std::string getDescription();

	// create another one of these
	virtual AbstractObject* newInstance();

	// init & update
	virtual void init();
	virtual void update(double dt);

	// push its static functions into the given lua table
	virtual void pushStaticFuncs(lua_State* L);

	virtual ~PlSDLMixer();

	//LIAG_THESE
	int initMixer(int audioFreq, int numChannels, int chunkSize);
	int initMixerDefaultSettings();
	int loadWAV(std::string fn);
	int loadMUS(std::string fn);
	int deleteChunk(int pos);
	int deleteMusic(int pos);
	//STOP_LIAG

	Mix_Chunk* getChunk(int slot);
	Mix_Music* getMusic(int slot);

	static int li_initMixer(lua_State* L);
	static int li_initMixerDefaultSettings(lua_State* L);
	static int li_loadWAV(lua_State* L);
	static int li_loadMUS(lua_State* L);
	static int li_deleteChunk(lua_State* L);
	static int li_deleteMusic(lua_State* L);
	
private:
	bool _initted;
	RefTable<Mix_Chunk> _mixChunks;
	RefTable<Mix_Music> _musChunks;
};

#endif